<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition template="../default/template.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:consult="http://www.consult.com.br/jsf/consultutils"
	xmlns:web="http://www.web.com.br/jsf/webutils">

	<ui:define name="contentConsult">

		<fieldset id="fieldCustoOperacao" style="padding: 10px;">

			<legend style="font-weight: bold; font-size: 16px; width: auto;">#{messages['global.aviso.fieldset']}</legend>

			<h:panelGrid columns="1">

				<web:outputTextField id="msgCustoOperacao"
					value="#{exclusaoUI.msgCustoOperacaoExcluir}" required="false"
					width="620px" align="left" />

			</h:panelGrid>

		</fieldset>

		<!-- Fieldset de Busca -->
		<fieldset id="fieldFiltrosConsultar" style="padding: 10px;">

			<legend style="font-weight: bold; font-size: 16px; width: auto;">#{messages['global.filtros.fieldset']}</legend>

			<h:panelGrid columns="1">

				<!-- Bloco de Entidade -->
				<h:panelGrid columns="5">

					<web:outputTextField id="entidadeLabel"
						value="#{messages['restricao.entidade']}:" required="true"
						width="120px" align="right" />

					<web:fieldInputText id="entidadeCodigo"
						value="#{exclusaoUI.filter.associado.entidade.codigo}"
						required="true" width="70px"
						readonly="#{exclusaoUI.filter.entidadeDisabled}" />

					<p:commandButton id="entidadeSearch" icon="ui-icon-search"
						disabled="#{exclusaoUI.filter.entidadeDisabled}" />

					<web:fieldInputText id="entidadeRazaoSocial"
						value="#{exclusaoUI.filter.associado.entidade.razaoSocial}"
						required="false" width="310px" readonly="true" />

					<p:message for="entidadeCodigoText" id="entidadeCodigo_message"
						display="text" redisplay="true" />

				</h:panelGrid>
				<!-- ************ -->

				<!-- Bloco de Associado -->
				<h:panelGrid columns="5">

					<web:outputTextField id="associadoLabel"
						value="#{messages['restricao.associado']}:" required="true"
						width="120px" align="right" />

					<web:fieldInputText id="associadoCodigo"
						value="#{exclusaoUI.filter.associado.codigo}" required="true"
						width="70px" readonly="#{exclusaoUI.filter.associadoDisabled}">

						<p:ajax listener="#{exclusaoUI.associadoLocate}" update="@form" />

					</web:fieldInputText>

					<p:commandButton id="associadoSearch" icon="ui-icon-search"
						disabled="#{exclusaoUI.filter.associadoDisabled}" process="@this"
						update="_searchAssociadoDialogForm"
						actionListener="#{associadoUI.reset}"
						onsuccess="PF('searchAssociadoDialog').show()" global="false" />

					<web:fieldInputText id="associadoRazaoSocial"
						value="#{exclusaoUI.filter.associado.razaoSocial}"
						required="false" width="310px" readonly="true" />

					<p:message for="associadoCodigoText" id="associadoCodigo_message"
						display="text" redisplay="true" />

				</h:panelGrid>
				<!-- ************** -->

				<!-- Botões -->
				<h:panelGrid columns="2">

					<web:outputTextField id="btnIncluirLabel" value=".:"
						required="false" width="120px" align="right" />

					<web:field for="btnExcluirSearch" mode="1" required="false"
						addMessage="false">

						<p:commandButton id="btnExcluirSearch"
							value="#{messages['global.msg.search']}" update="@form"
							action="#{exclusaoUI.search}" process="@this"
							style="margir-left: 5px;" />

						<p:commandButton id="excluirResetLnk"
							value="#{messages['global.msg.reset']}" immediate="true"
							action="#{exclusaoUI.prepareSearch}" update="@form" process="@this" />

					</web:field>

				</h:panelGrid>
				<!-- ************** -->

			</h:panelGrid>

		</fieldset>
		<!-- ************** -->

		<!-- Fieldset de Resultados -->
		<fieldset id="fieldFiltros" style="padding: 10px;">

			<legend style="font-weight: bold; font-size: 16px; width: auto;">#{messages['global.resultados.fieldset']}</legend>

			<p:panelGrid columns="2" rendered="#{not empty exclusaoUI.restricoes}">

				<h:outputText 
					style="text-align: right; display: block; width: 120px;"
					value="#{messages['global.total.registros']}: &nbsp;">
				</h:outputText>

				<h:outputText
					style="text-align: center; display: block; font-weight: bold;"
					value="#{exclusaoUI.restricoes.size()} #{messages['global.registros.encontrados']}">
				</h:outputText>

			</p:panelGrid>

			<web:dataTable id="restricoesAssociado" paginator="false"
				rendered="#{not empty exclusaoUI.restricoes}" value="#{exclusaoUI.restricoes}"
				rows="1000">

				<ui:define name="columns">

					<web:column id="columnBotaoExcluir" align="center">

						<p:commandButton id="removerBtn" process="@this" immediate="true"
							update="_deleteDialogForm" oncomplete="PF('deleteDialog').show()"
							title="#{messages['global.msg.excluir']}" icon="ui-icon-trash">

							<f:setPropertyActionListener value="#{dataTableItem}"
								target="#{exclusaoUI.restricaoSelected}" />

						</p:commandButton>

					</web:column>

					<web:column id="columnDataRestricao"
						title="#{messages['restricao.listagem.data.restricao.header']}"
						align="center">
						<h:outputText style="text-align: center; display: block;"
							value="#{dataTableItem.dataRestricao}">
							<f:convertDateTime pattern="dd/MM/yyyy"
								locale="#{localeUI.locale}" timeZone="#{timezoneUI.timeZone}" />
						</h:outputText>
					</web:column>

					<web:column id="columnDataVencto"
						title="#{messages['restricao.listagem.data.vencimento.header']}"
						align="center">
						<h:outputText style="text-align: center; display: block;"
							value="#{dataTableItem.dataVencimento}">
							<f:convertDateTime pattern="dd/MM/yyyy"
								locale="#{localeUI.locale}" timeZone="#{timezoneUI.timeZone}" />
						</h:outputText>
					</web:column>

					<web:column id="columnCpf"
						title="#{messages['restricao.listagem.contraparte.cpf.header']}"
						align="center">
						<h:outputText style="text-align: center; display: block;"
							value="#{dataTableItem.contraparte.cpf}">
						</h:outputText>
					</web:column>

					<web:column id="columnNome"
						title="#{messages['restricao.listagem.contraparte.nome.header']}"
						align="center">
						<h:outputText style="text-align: center; display: block;"
							value="#{dataTableItem.contraparte.nome}">
						</h:outputText>
					</web:column>

					<web:column id="columnContrato"
						title="#{messages['restricao.listagem.contrato.header']}"
						align="center">
						<h:outputText style="text-align: center; display: block;"
							value="#{dataTableItem.contrato}">
						</h:outputText>
					</web:column>

					<web:column id="columnValor"
						title="#{messages['restricao.listagem.valor.debito.header']}"
						align="center">
						<h:outputText style="text-align: center; display: block;"
							value="#{dataTableItem.valorDebito}">
							<f:convertNumber locale="#{localeUI.locale}"
								pattern="R$ ###,###,###.##" />
						</h:outputText>
					</web:column>

				</ui:define>

			</web:dataTable>

		</fieldset>
		<!-- ************** -->

	</ui:define>

	<ui:define name="dialogs">

		<!-- Janela de Confirmação de Exclusão -->
		<p:dialog id="deleteDialog"
			header="#{web:nvl(deleteMessage,messages['global.msg.confirmar_exclusao'])}"
			widgetVar="deleteDialog" resizable="false" modal="true">

			<h:form id="deleteDialogForm" enctype="multipart/form-data">

				<p:panelGrid columns="2">
	
					<h:outputText
						style="text-align: right; display: block; width: 120px;"
						value="#{messages['restricao.listagem.contraparte.cpf.header']}: &nbsp;">
					</h:outputText>
	
					<h:outputText
						style="text-align: center; display: block; font-weight: bold;"
						value="#{exclusaoUI.restricaoSelected.contraparte.cpf}">
					</h:outputText>
	
				</p:panelGrid>
	
				<p:panelGrid columns="2">
	
					<h:outputText
						style="text-align: right; display: block; width: 120px;"
						value="#{messages['restricao.listagem.contraparte.nome.header']}: &nbsp;">
					</h:outputText>
	
					<h:outputText
						style="text-align: center; display: block; font-weight: bold;"
						value="#{exclusaoUI.restricaoSelected.contraparte.nome}">
					</h:outputText>
	
				</p:panelGrid>
	
				<p:panelGrid columns="2">
	
					<h:outputText
						style="text-align: right; display: block; width: 120px;"
						value="#{messages['restricao.listagem.valor.debito.header']}: &nbsp;">
					</h:outputText>
	
					<h:outputText
						style="text-align: center; display: block; font-weight: bold;"
						value="#{exclusaoUI.restricaoSelected.valorDebito}">
						<f:convertNumber locale="#{localeUI.locale}"
							pattern="R$ ###,###,###.##" />
					</h:outputText>
	
				</p:panelGrid>
				
				<p:panelGrid columns="2">
	
					<h:outputText
						style="text-align: right; display: block; width: 120px;"
						value="#{messages['restricao.listagem.data.restricao.header']}: &nbsp;">
					</h:outputText>
	
					<h:outputText style="text-align: center; display: block; font-weight: bold;"
						value="#{exclusaoUI.restricaoSelected.dataRestricao}">
						<f:convertDateTime pattern="dd/MM/yyyy"
							locale="#{localeUI.locale}" timeZone="#{timezoneUI.timeZone}" />
					</h:outputText>
				
				</p:panelGrid>
				
				<center>
					<p:commandButton value="#{messages['global.yes']}"
						action="#{exclusaoUI.save}" immediate="true" ajax="true"
						update="@form" onsuccess="PF('deleteDialog').hide()"
						id="deleteDialog_btnYes">
					</p:commandButton>
			
					<p:commandButton value="#{messages['global.no']}"
						onclick="PF('deleteDialog').hide()" id="deleteDialog_btnNo" />
				</center>

			</h:form>

		</p:dialog>
		<!-- ***************************** -->

		<consult:dialogAssociado backingBean="#{exclusaoUI}" />

	</ui:define>

</ui:composition>